import {Component, OnInit} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {VideoModule} from '../video.module';
import {Videotab} from '../videotab';
import {VideoService} from '../video.service';
import {NzMessageService} from 'ng-zorro-antd';

@Component({
    selector: 'app-videotypelist',
    templateUrl: './videotypelist.component.html',
})
export class VideotypelistComponent implements OnInit {

    data: Videotab[] = [];
    // total = 0;
    // pagesize = 10;
    // pageCureent = 1;

    // currentType = -1;


    constructor(
        private videoService: VideoService,
        private msg: NzMessageService,
    ) {
    }

    ngOnInit() {
        this.getlist(1);
    }

    getlist($event) {
        this.videoService.getlaylist($event - 1).subscribe(res => {
            this.data = res;
        });
    }

    del(item: Videotab, index: number) {
        this.data = [...this.data.slice(0, index), ...this.data.slice(index + 1, this.data.length)];
        this.videoService.dellay(item.id).subscribe(res => {
            this.msg.success('删除成功');
        }, error1 => {
            this.videoService.getlaylist(0);
        });

    }
}
